<?php

namespace app\merchant\model;

use think\Model;

/**
 * 标的基本表
 */
class TpBorrow extends Model
{
    //设置当前模型对应的完整数据表名称
    protected $table = 'tp_borrow';
    
     //新发布，待审核
    const STATUS_NEW = 1;
    //初审未通过
    const STATUS_VIEW_FAILED = 2;
    //初审通过，投标中
    const STATUS_INVESTOR = 3;
    //流标
    const STATUS_TEND = 4;
    //标的已满额，满额复核中
    const STATUS_FULL = 5;
    //放款成功，还款中
    const STATUS_PAY_SUCCESS = 6;
    //放款失败
    const STATUS_PAY_FAILED = 7;
    //还款代收完成(不合理，暂不使用)
    const STATUS_REPAYMENT_COLLECTION_SUCCESS = 8;
    //还款代付完成，还款完成
    const STATUS_REPAYMENT_PAY_SUCCESS = 9;
    //还款代收失败
    const STATUS_REPAYMENT_FAILED_1 = 10;
    //还款代付失败
    const STATUS_REPAYMENT_FAILED_2 = 11;
    //流标处理中
    const STATUS_TEND_PROCESSING = 12;
    //提前还款处理中
    const STATUS_PREPAY_PROCESSING = 13;
    //提前还款处理完成
    const STATUS_PREPAY_SUCCESS = 14;
    
    /**
     * 获取状态列表
     * @return type
     */
    public static function getStatusList()
    {
        return [
            self::STATUS_NEW => '待审核',
            self::STATUS_VIEW_FAILED => '初审未通过',
            self::STATUS_INVESTOR => '投标中',
            self::STATUS_TEND => '流标',
            self::STATUS_FULL => '满额复核中',
            self::STATUS_PAY_SUCCESS => '还款中',
            self::STATUS_PAY_FAILED => '放款失败',
            self::STATUS_REPAYMENT_COLLECTION_SUCCESS => '还款代收完成',
            self::STATUS_REPAYMENT_PAY_SUCCESS => '还款完成',
            self::STATUS_REPAYMENT_FAILED_1 => '还款代收失败',
            self::STATUS_REPAYMENT_FAILED_2 => '还款代付失败',
            self::STATUS_TEND_PROCESSING => '流标处理中',
            self::STATUS_PREPAY_PROCESSING => '提前还款处理中',
            self::STATUS_PREPAY_SUCCESS => '提前还款处理完成',
        ];
    }
    
    /**
     * 获取状态名称
     * @param type $status
     * @return type
     */
    public static function getStatusName($status) {
        $list = [
            self::STATUS_NEW => '待审核',
            self::STATUS_VIEW_FAILED => '初审未通过',
            self::STATUS_INVESTOR => '投标中',
            self::STATUS_TEND => '流标',
            self::STATUS_FULL => '满额复核中',
            self::STATUS_PAY_SUCCESS => '还款中',
            self::STATUS_PAY_FAILED => '放款失败',
            self::STATUS_REPAYMENT_COLLECTION_SUCCESS => '还款代收完成',
            self::STATUS_REPAYMENT_PAY_SUCCESS => '还款完成',
            self::STATUS_REPAYMENT_FAILED_1 => '还款代收失败',
            self::STATUS_REPAYMENT_FAILED_2 => '还款代付失败',
            self::STATUS_TEND_PROCESSING => '流标处理中',
            self::STATUS_PREPAY_PROCESSING => '提前还款处理中',
            self::STATUS_PREPAY_SUCCESS => '提前还款处理完成',
        ];
        
        return isset($list[$status]) ? $list[$status] : '未知状态码：[' . $status . ']';
    }
}
